package cn.fczds.camhelper.user.controller;

import cn.fczds.camhelper.base.response.JsonResult;
import cn.fczds.camhelper.user.pojo.dto.*;
import cn.fczds.camhelper.user.pojo.vo.UserVO;
import cn.fczds.camhelper.user.service.UserService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@Slf4j
@RestController
@RequestMapping("v1/user/")
public class UserController {
    @Autowired
    UserService userService;

    @PostMapping("login")
    public JsonResult login(UserLoginParam userLoginParam) {
        log.debug("userLoginParam:{}", userLoginParam);
        UserVO userVO = userService.login(userLoginParam);
        log.debug("出参userVO={}",userVO);
        return JsonResult.ok(userVO);
    }
    @PostMapping("reg")
    public JsonResult reg(UserSaveParam userSaveParam) {
        log.debug("注册参数usersaveparam={}",userSaveParam);
        userService.reg(userSaveParam);
        return JsonResult.ok();
    }

    @GetMapping("select")
    public JsonResult select(UserInfoQuery userInfoQuery) {
        log.debug("用户信息:UserInfoQuery{}" + userInfoQuery);
        List<UserVO> list = userService.select(userInfoQuery);
        return JsonResult.ok(list);
    }

    @PostMapping("update")
    public JsonResult update(UserUpdateParam userUpdateParam) {
        log.debug("userupdateParam={}",userUpdateParam);
        List<UserVO> list = userService.update(userUpdateParam);
        return JsonResult.ok(list);
    }

    @PostMapping("insertMsg")
    public JsonResult insertMessage(UserMessageParam userMessageParam) {
        log.debug("userMessageParam={}",userMessageParam);
        userService.insertMessage(userMessageParam);
        return JsonResult.ok();
    }



}
